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

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

Moderators: cheriff, TyRaNiD

Post Reply
pavel1104
Posts: 2
Joined: Mon Apr 24, 2006 11:47 pm

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

Post by pavel1104 »

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: Select all

// 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&#40;"COUNTER PROGRAM", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf
/* 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;
int main&#40;&#41; &#123;
pspDebugScreenInit&#40;&#41;;
SetupCallbacks&#40;&#41;;
int counter = 0;
int i = 0; SceCtrlData pad;
printf&#40;"Press &#91;X&#93; To Start the Timer"&#41;;
sceKernelSleepThread&#40;&#41;;
return 0;
&#125;

while&#40;1&#41; &#123;
sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
                    break;
          &#125;
&#125;     
 while&#40;1&#41; &#123;
          sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
          if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; &#123;
                    break;
          &#125;    
pspDebugScreenClear&#40;&#41;;
printf&#40;"Press &#91;O&#93; To Stop the Timer\n"&#41;;
          printf&#40;"Counter&#58; %i", counter&#41;;
counter = counter +1;
for&#40;i=0; i<5; i++&#41; &#123;
                    sceDisplayWaitVblankStart&#40;&#41;;
          &#125;
pspDebugScreenClear&#40;&#41;;
printf&#40;"Counter Finished."&#41;;
printf&#40;"Final Count&#58; %i", counter&#41;;

Makefile

Code: Select all

TARGET = count
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = COUNTER PROGRAM

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/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.
mauve.simian
Posts: 5
Joined: Sun Apr 09, 2006 6:51 am

Post by mauve.simian »

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: Select all

// 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&#40;"COUNTER PROGRAM", 0, 1, 1&#41;;
#define printf pspDebugScreenPrintf
/* 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;

int main&#40;&#41; &#123;
  pspDebugScreenInit&#40;&#41;;
  SetupCallbacks&#40;&#41;;

  int counter = 0;
  int i = 0; SceCtrlData pad;
  printf&#40;"Press &#91;X&#93; To Start the Timer"&#41;;

  while&#40;1&#41; &#123;
    sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
    if&#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
       break;
    &#125;
  &#125;     

  while&#40;1&#41; &#123;
    sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
    if&#40;pad.Buttons & PSP_CTRL_CIRCLE&#41; &#123;
       break;
    &#125;   
    pspDebugScreenClear&#40;&#41;;
    printf&#40;"Press &#91;O&#93; To Stop the Timer\n"&#41;;
    printf&#40;"Counter&#58; %i", counter&#41;;
    counter = counter +1;
    for&#40;i=0; i<5; i++&#41; &#123;
      sceDisplayWaitVblankStart&#40;&#41;;
    &#125;
  &#125;
  pspDebugScreenClear&#40;&#41;;
  printf&#40;"Counter Finished."&#41;;
  printf&#40;"Final Count&#58; %i", counter&#41;;

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

pavel1104
Posts: 2
Joined: Mon Apr 24, 2006 11:47 pm

Post by pavel1104 »

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.
Giuliano
Posts: 78
Joined: Tue Sep 13, 2005 10:26 am

Post by Giuliano »

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 :)
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

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
ravenlife
Posts: 4
Joined: Thu Apr 27, 2006 10:05 am

Post by ravenlife »

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
Post Reply