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 

i am new to homebrew, and i need help making my first one

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



Joined: 24 Apr 2006
Posts: 2

PostPosted: Mon Apr 24, 2006 11:57 pm    Post subject: i am new to homebrew, and i need help making my first one Reply with quote

hey everybody,
i am finished the code, and i changed the makefile and when i type make into CYGWIN it says all these warnings and errors.
i ignore the warnings and read the errors. heres the code from my main.c file and from my makefile. so try it for yourself and can you tell me what i am doing wrong.

Main.c file:
Code:

// Hello World - My First App for the PSP

/*
          This program was created by Pavel on April, 23, 2006
          It is a simple "Hello World" Application.
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
PSP_MODULE_INFO("COUNTER PROGRAM", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* 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() {
pspDebugScreenInit();
SetupCallbacks();
int counter = 0;
int i = 0; SceCtrlData pad;
printf("Press [X] To Start the Timer");
sceKernelSleepThread();
return 0;
}

while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS) {
                    break;
          }
}     
 while(1) {
          sceCtrlReadBufferPositive(&pad, 1);
          if(pad.Buttons & PSP_CTRL_CIRCLE) {
                    break;
          }   
pspDebugScreenClear();
printf("Press [O] To Stop the Timer\n");
          printf("Counter: %i", counter);
counter = counter +1;
for(i=0; i<5; i++) {
                    sceDisplayWaitVblankStart();
          }
pspDebugScreenClear();
printf("Counter Finished.");
printf("Final Count: %i", counter);



Makefile
Code:

TARGET = count
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = COUNTER PROGRAM

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak


and there it is.

BTW i am using the crash course from http://www.scriptscribbler.com/psp/tutorials/
_________________
I am new to homebrew, so dont get mad if i ask stupid questions.
Back to top
View user's profile Send private message Send e-mail
mauve.simian



Joined: 09 Apr 2006
Posts: 5

PostPosted: Tue Apr 25, 2006 12:17 am    Post subject: Reply with quote

Don't have my psp on me so haven't tested it, but this at least compiles. Basically you had code outside of the main that I assume you wanted in there. There was also a missing '}'. If you want a better description than this let me know.


Code:
// Hello World - My First App for the PSP

/*
          This program was created by Pavel on April, 23, 2006
          It is a simple "Hello World" Application.
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
PSP_MODULE_INFO("COUNTER PROGRAM", 0, 1, 1);
#define printf pspDebugScreenPrintf
/* 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() {
  pspDebugScreenInit();
  SetupCallbacks();

  int counter = 0;
  int i = 0; SceCtrlData pad;
  printf("Press [X] To Start the Timer");

  while(1) {
    sceCtrlReadBufferPositive(&pad, 1);
    if(pad.Buttons & PSP_CTRL_CROSS) {
       break;
    }
  }     

  while(1) {
    sceCtrlReadBufferPositive(&pad, 1);
    if(pad.Buttons & PSP_CTRL_CIRCLE) {
       break;
    }   
    pspDebugScreenClear();
    printf("Press [O] To Stop the Timer\n");
    printf("Counter: %i", counter);
    counter = counter +1;
    for(i=0; i<5; i++) {
      sceDisplayWaitVblankStart();
    }
  }
  pspDebugScreenClear();
  printf("Counter Finished.");
  printf("Final Count: %i", counter);

  sceKernelSleepThread();
  return 0;
}

Back to top
View user's profile Send private message
pavel1104



Joined: 24 Apr 2006
Posts: 2

PostPosted: Tue Apr 25, 2006 9:45 am    Post subject: Reply with quote

yay it works!!! :D:D:D:D thx soooo much. i think i get it now. the define printf part and the { } stuff have to be in there.
_________________
I am new to homebrew, so dont get mad if i ask stupid questions.
Back to top
View user's profile Send private message Send e-mail
Giuliano



Joined: 13 Sep 2005
Posts: 78

PostPosted: Tue Apr 25, 2006 9:46 am    Post subject: Reply with quote

Make sure you understand WHY not just that it has to be there. That way when you see it being used a different way it's easier to understand it :)
Back to top
View user's profile Send private message
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Wed Apr 26, 2006 2:18 pm    Post subject: Reply with quote

first finish your C book/articals before posting
help me questions on basic C programming
this forum is first a developement forum
meaning you must already know how to develop
your problems are not psp specific and it shows
that you started to learn C with psp which is not
good in improving your programming ability
practice, practice, practice all you can on a
simple program binary made for the command shell
this will improve your ability thru simple trial and error
studies and will make your mind out to see common
errors like those you posted above
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
ravenlife



Joined: 27 Apr 2006
Posts: 4

PostPosted: Thu Apr 27, 2006 9:18 pm    Post subject: Reply with quote

if you want some good (i think) tutorials for begginers and advanced users you can go here http://www.cprogramming.com/

they also have a message board dedicated to begginers - obviously they are not psp but they will be able to help you out on most things
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