Need help with compiling my first simple homebrew

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

Moderators: cheriff, TyRaNiD

Post Reply
bykte
Posts: 3
Joined: Sun Jun 01, 2008 1:51 pm

Need help with compiling my first simple homebrew

Post by bykte »

Hello everyone,

Firstly, I have followed the guide from http://forums.qj.net/f-psp-development- ... 00222.html and have successfully gotten a PSP development environment working.

Secondly, my first attempt was to compile the samples from the PSPSDK and running it through my PSP. Mine's a SLIM edition with 3.90m33-3 CFW. However, I simply cannot get the EBOOT.PBP compiled from the samples working on my PSP. Here's the problem: My PSP will shutdown by itself within a few seconds of executing the homebrew. I have tried a simple hello world and the results are sadly the same. Anyone knows what I might have done wrongly? Please enlighten me. Thanks in advance.

One of the samples I tried is the controller/basic.

Makefile

Code: Select all

TARGET = controller_basic
OBJS = main.o
 
INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
 
BUILD_PRX = 1
PSP_FW_VERSION = 390
 
LIBDIR =
LDFLAGS =
 
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Basic controller sample
 
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
main.c

Code: Select all

/*
 * PSP Software Development Kit - http://www.pspdev.org
 * -----------------------------------------------------------------------
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
 *
 * main.c - Basic Input demo -- reads from control pad and indicates button
 *          presses.
 *
 * Copyright &#40;c&#41; 2005 Marcus R. Brown <[email protected]>
 * Copyright &#40;c&#41; 2005 James Forshaw <[email protected]>
 * Copyright &#40;c&#41; 2005 John Kelley <[email protected]>
 * Copyright &#40;c&#41; 2005 Donour Sizemore <[email protected]>
 *
 * $Id&#58; main.c 1095 2005-09-27 21&#58;02&#58;16Z jim $
 */
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>

/* Define the module info section */
PSP_MODULE_INFO&#40;"CONTROLTEST", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

/* Define printf, just to make typing easier */
#define printf	pspDebugScreenPrintf

void dump_threadstatus&#40;void&#41;;

int done = 0;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	done = 1;
	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;

int main&#40;void&#41;
&#123;
	SceCtrlData pad;

	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;

	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

	while&#40;!done&#41;&#123;
		pspDebugScreenSetXY&#40;0, 2&#41;;

    		sceCtrlReadBufferPositive&#40;&pad, 1&#41;; 

		printf&#40;"Analog X = %d ", pad.Lx&#41;;
		printf&#40;"Analog Y = %d \n", pad.Ly&#41;;

		if &#40;pad.Buttons != 0&#41;&#123;
			if &#40;pad.Buttons & PSP_CTRL_SQUARE&#41;&#123;
				printf&#40;"Square pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_TRIANGLE&#41;&#123;
				printf&#40;"Triangle pressed \n"&#41;;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;&#123;
				printf&#40;"Cicle pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
				printf&#40;"Cross pressed \n"&#41;;
			&#125; 

			if &#40;pad.Buttons & PSP_CTRL_UP&#41;&#123;
				printf&#40;"Up pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_DOWN&#41;&#123;
				printf&#40;"Down pressed \n"&#41;;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_LEFT&#41;&#123;
				printf&#40;"Left pressed \n"&#41;;
			&#125; 
			if &#40;pad.Buttons & PSP_CTRL_RIGHT&#41;&#123;
				printf&#40;"Right pressed \n"&#41;;
			&#125;      

			if &#40;pad.Buttons & PSP_CTRL_START&#41;&#123;
				printf&#40;"Start pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_SELECT&#41;&#123;
				printf&#40;"Select pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_LTRIGGER&#41;&#123;
				printf&#40;"L-trigger pressed \n"&#41;;
			&#125;
			if &#40;pad.Buttons & PSP_CTRL_RTRIGGER&#41;&#123;
				printf&#40;"R-trigger pressed \n"&#41;;
			&#125;      
		&#125;
	&#125;

	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;
p.s. I could be experiencing the same problem as http://forums.ps2dev.org/viewtopic.php?t=10407
Last edited by bykte on Sun Jun 01, 2008 2:27 pm, edited 1 time in total.
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

you havent defined your HEAP size.

Try PSP_HEAP_SIZE_KB(20480);

in the main.c file :)

Wally
bykte
Posts: 3
Joined: Sun Jun 01, 2008 1:51 pm

Post by bykte »

Wally4000 wrote:you havent defined your HEAP size.

Try PSP_HEAP_SIZE_KB(20480);

in the main.c file :)

Wally
Thanks for your reply, Wally.

I have edited the main.c by adding

Code: Select all

PSP_HEAP_SIZE_KB&#40;20480&#41;; 
and the results are still the same; PSP shutdowns by itself with a "poof" like sound.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Add a delay to your loop. You're blasting through the loop as fast as the PSP can go. Some things won't work like that. You should add an sceKernelDelayThread() or a wait on the vertical blank.
Post Reply