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 

Need help with compiling my first simple homebrew

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



Joined: 01 Jun 2008
Posts: 3

PostPosted: Sun Jun 01, 2008 1:59 pm    Post subject: Need help with compiling my first simple homebrew Reply with quote

Hello everyone,

Firstly, I have followed the guide from http://forums.qj.net/f-psp-development-forum-11/t-guide-psp-development-environment-setup-tutorial-100222.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:

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:

/*
 * 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 (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
 * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
 * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
 * Copyright (c) 2005 Donour Sizemore <donour@uchicago.edu>
 *
 * $Id: main.c 1095 2005-09-27 21:02: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("CONTROLTEST", 0, 1, 1);

/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

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

void dump_threadstatus(void);

int done = 0;

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
   done = 1;
   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(void)
{
   SceCtrlData pad;

   pspDebugScreenInit();
   SetupCallbacks();

   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

   while(!done){
      pspDebugScreenSetXY(0, 2);

          sceCtrlReadBufferPositive(&pad, 1);

      printf("Analog X = %d ", pad.Lx);
      printf("Analog Y = %d \n", pad.Ly);

      if (pad.Buttons != 0){
         if (pad.Buttons & PSP_CTRL_SQUARE){
            printf("Square pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_TRIANGLE){
            printf("Triangle pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_CIRCLE){
            printf("Cicle pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_CROSS){
            printf("Cross pressed \n");
         }

         if (pad.Buttons & PSP_CTRL_UP){
            printf("Up pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_DOWN){
            printf("Down pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_LEFT){
            printf("Left pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_RIGHT){
            printf("Right pressed \n");
         }     

         if (pad.Buttons & PSP_CTRL_START){
            printf("Start pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_SELECT){
            printf("Select pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_LTRIGGER){
            printf("L-trigger pressed \n");
         }
         if (pad.Buttons & PSP_CTRL_RTRIGGER){
            printf("R-trigger pressed \n");
         }     
      }
   }

   sceKernelExitGame();
   return 0;
}


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



Joined: 26 Sep 2005
Posts: 672

PostPosted: Sun Jun 01, 2008 2:27 pm    Post subject: Reply with quote

you havent defined your HEAP size.

Try PSP_HEAP_SIZE_KB(20480);

in the main.c file :)

Wally
Back to top
View user's profile Send private message AIM Address
bykte



Joined: 01 Jun 2008
Posts: 3

PostPosted: Sun Jun 01, 2008 2:29 pm    Post subject: Reply with quote

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:
PSP_HEAP_SIZE_KB(20480);


and the results are still the same; PSP shutdowns by itself with a "poof" like sound.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Jun 01, 2008 3:12 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
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