Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff , TyRaNiD
pavel1104
Posts: 2 Joined: Mon Apr 24, 2006 11:47 pm
Post
by pavel1104 » Mon Apr 24, 2006 11:57 pm
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("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: Select all
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.
mauve.simian
Posts: 5 Joined: Sun Apr 09, 2006 6:51 am
Post
by mauve.simian » Tue Apr 25, 2006 12:17 am
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("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;
}
pavel1104
Posts: 2 Joined: Mon Apr 24, 2006 11:47 pm
Post
by pavel1104 » Tue Apr 25, 2006 9:45 am
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 » Tue Apr 25, 2006 9:46 am
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 :)
dot_blank
Posts: 498 Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil
Post
by dot_blank » Wed Apr 26, 2006 2:18 pm
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 » Thu Apr 27, 2006 9:18 pm
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