and after u have to keep pspDebugScreenInit(); coz It won't show your msg :)
And Can u give me your makefile
don't try its still doesn't work ... lol
you intreduce your main function like this
Code:int main()
{
//blblblblblblblah;
}
Printable View
and after u have to keep pspDebugScreenInit(); coz It won't show your msg :)
And Can u give me your makefile
don't try its still doesn't work ... lol
you intreduce your main function like this
Code:int main()
{
//blblblblblblblah;
}
Sethis: Post all your code.
Bronx: That's incorrect. You can have \n anywhere in a string.
lol the thing is that his main starts like thisZitat:
Zitat von head_54us
that means he is calling his main that is doesn't even existZitat:
int main();
So he does, looks like he forgot a '{' as well.
heres my makefile.Code://Program for psp, push a button to disappear
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
PSP_MODULE_INFO ("Hello World Project 1.", 0, 1, 1);
/* 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(){
SetupCallBacks();
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\n Press [X] to clear sceen.");
sceCtrlData pad;
while(1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons &PSP_CTRL_CROSS) {
pspDebugScreenClear ();
}
}
return 0;
}
TARGET = Dislpay and Clear
OBJS = main.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Display and Clear
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
thanks
put sceCtrlData pad; top before printing
there is no space btw if and the (
IF(asfjafasfa) {
}
ok?
Corrected code. White space doesn't matter in syntax. This would still compile:Code:int main()
{
SetupCallbacks(); // Typo here. Was SetupCallBacks(). Note the capital B
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\n Press [X] to clear sceen.");
SceCtrlData pad; // Typo here. Was sceCtrlData. Note the small s.
while (1)
{
sceCtrlPeekBufferPositive(&pad, 1);
if ( pad.Buttons & PSP_CTRL_CROSS )
{
pspDebugScreenClear ();
}
}
return 0;
}
OT: I really don't like the SDK's naming convention. Data structures begin with a capital letter and functions with a lowercase.Code:if
(
pad.Buttons
&
PSP_CTRL_CROSS
)
lol I just found out what is the problem and u ahve to change something in your makefile:
TARGET = DislpayandClear
there can't be any spaces in making target
lol .....Zitat:
White space doesn't matter in syntax
well thats why a lot of times you have to coppy ;)Zitat:
I really don't like the SDK's naming convention
That white space error in the TARGET is not syntax, its from putting whitespace in a value if we really want to get techincal :PZitat:
Zitat von the unique warrior
check it your self ..... if there will be any white space btw Display / and / clear there will be an error on cygwin ;)
its looking better. i never knew that i can have spaces in the makefile. xD. anyways the compiling is starting to get less errors heres what i get now. i just need minor adjustments and ill be done :D what are they lol Thanks :D
$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
main.c: In function 'main':
main.c:38: warning: implicit declaration of function 'SetupCallBacks'
main.c:41: error: 'sceCtrlData' undeclared (first use in this function)
main.c:41: error: (Each undeclared identifier is reported only once
main.c:41: error: for each function it appears in.)
main.c:41: error: syntax error before 'pad'
main.c:43: error: 'pad' undeclared (first use in this function)
make: *** [main.o] Error 1
the unique warrior: Like I said, that was an error in the string value not the makefile syntax ;). Big difference :P. (Yeah, I am just being pedantic).
Sethis: Did you actually see the corrected code that I gave?
again :
-= Double Post =-Code:int main()
{
SetupCallbacks(); // Typo here. Was SetupCallBacks(). Note the capital B
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\n Press [X] to clear sceen.");
SceCtrlData pad; // Typo here. Was sceCtrlData. Note the small s.
while (1)
{
sceCtrlPeekBufferPositive(&pad, 1);
if ( pad.Buttons & PSP_CTRL_CROSS )
{
pspDebugScreenClear ();
}
}
return 0;
}
u will see after he finishes all the other problems in the program he will face a big error in his make file :).Zitat:
Zitat von head_54us
Again, the 'second' error will be due to another string value error rather then makefile syntax although I concede that it causes a knock on effect onto the sytnax. Ahhh.. screw it, can't be assed now :P.
Now this is the reason why I am using an IDE, saves all this hassle of dealing with makefiles :).
o0 intresting
Yes i did see your correction code head_54us. In the make file the target must have no spaces. Or i missed it :s.......there are soo many posts :S sorry if i missed it. But yes i did fix that...
edit: thanks guys, it compiled. but now i got more questions... xD
1. the SetupCallbacks - once before was capital and it compiled. same with sce it was capital and it compiled. maybe my eyes are being dislexic again and i should relook that code xD...Thanks guys, i really appreciate this :D. anyways if you want the code and see what i did then just ask. you probably wont becuase you can do it yourself. Thanks :D
Zitat:
Zitat von head_54us
I wonder if I could configure it to work with Xcode... Anyone know?Zitat:
Zitat von the unique warrior
Well it works :D.thanks to everyone here :D. now i am trying to have my program display something, then erease it. then print something else back to the screen. Would i need a separate function to do this... i dont know. I tried to implement it like this
its wrong definitly so i need someone NOT to give me the actual code, but to tell me how this is suppose to be done. that way i could learn :D. Thanks i will probably check back tomorrow. i gotta whip up some history notes for school xDCode:
int main(){
SetupCallbacks();
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\nPress [X] to clear sceen. \n\nPress [O] to Reappear.");
SceCtrlData pad;
while(1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons &PSP_CTRL_CROSS) {
pspDebugScreenClear ();
if (pad.Buttons &PSP_CTRL_CIRCLE) {
pspDebugScreenPrintf ("Hello World. \n\nPress [X] to clear Screen. \n\nPress [O] to Reappear.");
}
return 0;
}
}
}
STOP indenting horribly, it throughs you off and thus maeks your program useless. Anyway, that does what you want i suppose. But, not the:Code:int main() {
SetupCallbacks();
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\nPress [X] to clear sceen. \n\nPress [O] to Reappear.");
SceCtrlData pad;
while(1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS) {
pspDebugScreenClear ();
}
if (pad.Buttons & PSP_CTRL_CIRCLE) {
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf ("Hello World. \n\nPress [X] to clear Screen. \n\nPress [O] to Reappear.");
}
}
return 0;
}
pspDebugScreenSetXY(0,0);
This little thing will print any text from then on, at thecharacter cells 0 - x, 0 - y. This will prevent multiple lines of hello world, press [x], press [o] thing. Just for a better view, comment out the
pspDebugScreenSetXY(0,0);
line and see what happens ;)
ya well SG that doesnt exactly fit in with the way Im trying to do it, just trying to make some standard multiple bullets everytime I press RIGHT.Zitat:
Zitat von Gonrai
SG57 Thanks.
Can you post an example of how i that works. i didnt exactly understand that xD....as you can tell i am a total noob.
How can i add it to my code? Thanks :DCode:
pspDebugScreenSetXY(0,0);
You just call that right before the printf command.Zitat:
Zitat von Sethis
Like this
Code:pspDebugScreenSetXY(0,0);
printf("Hello!!111one");
//pspDebugScreenPrintf("Hello!!111one");
I got a problem which I'm just not able to fix.
I got a global unsigned int called cadd.
and I run this code:
now it prints 08B5E090 just as I want it too.Code:cadd=String2Int(textfound);
printhex(cadd,8);
but after that comes this:
now here comes the problem, this time when it prints cadd, it prints 0. So I wonder, how can cadd suddenly have turned into 0 now? none of the functions touch it. It can't just change itself all of the sudden http://forums.qj.net/user_pics/38805-1158412981.gifCode:if(errorpos>=0) { printerror(buffer); break; }//this if statements is false.
if(cadd>0x09FFFFFF-setwhat||cadd<0x08400000) { printerror(buffer); printhex(cadd,8); break; }
Argh....Well the program works KIND OF. When i press X the screen clears and displays me a new message. What i want it to do now is be able to push X or O so that different things can appear when you see my code youll understand. Thanks
SG57 when you said stop indenting horribly what did you mean? am i inndenting to far in? or am i inconsistent with my indenting? Anywas im due for dinner See ya:D thanksCode:
int main(){
SetupCallbacks();
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\nPress [X] to clear sceen and Display Hi ALL. \n\nPress [O] to show Author.");
SceCtrlData pad;
while(1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons &PSP_CTRL_CROSS) {
pspDebugScreenClear ();
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf("Hi ALL");
if (pad.Buttons &PSP_CTRL_CIRCLE) {
pspDebugScreenClear ();
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf ("My name is Ac. I developed this program becuase i want to learn.");
}
return 0;
}
}
}
Edit:also i was told that i need the code
sceKernalSleepThread();
but i dont have it and it still works. why is this? im like lost now. Anyone? Thanks. Time for dinner :D
I am currently using Codeblocks and DevkitPSP using this setup:
http://www.psp-programming.com/dev-f...ic.php?p=12425
My Hello World program seems to shut down the PSP when ran from IrShell.
Anyone got any ideas?
Code:// Hello World - A simple "Hello World" Application.
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
PSP_MODULE_INFO("Hello World", 0, 1, 1);
// Exit callback
int ExitCallback(int Arg1, int Arg2, void *Common)
{
sceKernelExitGame();
return 0;
}
// Callback thread
int CallbackThread(SceSize Args, void *Argp)
{
int CallbackId;
CallbackId = sceKernelCreateCallback("Exit Callback", ExitCallback, NULL);
sceKernelRegisterExitCallback(CallbackId);
sceKernelSleepThreadCB();
return 0;
}
// Sets up the callback thread and returns its thread id
int SetupCallbacks(void)
{
int ThreadId = 0;
ThreadId = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (ThreadId >= 0)
{
sceKernelStartThread(ThreadId, 0, 0);
}
return ThreadId;
}
int main(int argc, char ** argv)
{
pspDebugScreenInit();
SetupCallbacks();
while(true)
{
pspDebugScreenPrintf ("Hello World");
sceDisplayWaitVblankStart();
}
sceKernelSleepThread();
return 0;
}
Your indents are huge yes.
sceKernelSleepThread() simply sleeps the thread, ie. without it your game would exit back to the XMB. With it it'll wait for you to exit it yourself with the home button or by similar means.Code:int main(){
SetupCallbacks();
pspDebugScreenInit();
pspDebugScreenPrintf ("Hello World. \n\nPress [X] to clear sceen and Display Hi ALL. \n\nPress [O] to show Author.");
SceCtrlData pad;
while(1) {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons &PSP_CTRL_CROSS) {
pspDebugScreenClear ();
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf("Hi ALL");
} //ADDED THIS
if (pad.Buttons &PSP_CTRL_CIRCLE) {
pspDebugScreenClear ();
pspDebugScreenSetXY(0,0);
pspDebugScreenPrintf ("My name is Ac. I developed this program becuase i want to learn.");
}
//IF YOU WERE TO HAVE A sceKernelSleepThread() IT WOULD BE HERE
//} REMOVED THIS
} //END WHILE LOOP
return 0;
} //END MAIN FUNCTION
Also note that the two pspDebugScreenSetXY(0, 0); are not needed in this case as you are calling pspDebugScreenClear(); right before them - which resets the X & Y to 0 anyway.
head_54us: Is there any way you can show us the steps that code::blocks takes when compiling your given code? ie. a visual output like what cygwin produces. Would help track the problem down.
Ok. well im gonnna try to compile it now, Also when i tried the code earlier without sceSleepKernelThread (); it didnt exit? what. is it the exit call backs? Thanks
Insomniac197: Afraid not. I suspect that I may need to actually build the eboot from the elf file that is created. However I am not 100% sure that is the problem.
Edit: Nope. Converted it to an eboot and it still doesn't work :/
Well I tried compiling it through cygwin (I changed the while(true) to while(1)) and it worked as expected.
This is my cygwin output when compiling - maybe it will highlight a step that you are missing.
Code:$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -L/usr/local/
pspdev/psp/sdk/lib main.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
-lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspus
er -lpspkernel -o hello.elf
psp-fixup-imports hello.elf
mksfo 'Hello World' PARAM.SFO
psp-strip hello.elf -o hello_strip.elf
pack-pbp EBOOT.PBP PARAM.SFO NULL \
NULL NULL NULL \
NULL hello_strip.elf NULL
rm -f hello_strip.elf
Hey, can anyone tlel me why im ONLY getting these undefined errors?
Im using GU (insomniac - u know what im talking about) if that helps. Anybody?Code:main.c:(.text+0x590): undefined reference to `__extendsfdf2'
main.c:(.text+0x5b0): undefined reference to `__muldf3'
main.c:(.text+0x5c0): undefined reference to `__extendsfdf2'
main.c:(.text+0x5d4): undefined reference to `__adddf3'
main.c:(.text+0x5e0): undefined reference to `__truncdfsf2'
main.c:(.text+0x5fc): undefined reference to `__muldf3'
main.c:(.text+0x60c): undefined reference to `__extendsfdf2'
main.c:(.text+0x620): undefined reference to `__adddf3'
main.c:(.text+0x62c): undefined reference to `__truncdfsf2'
main.c:(.text+0x63c): undefined reference to `__extendsfdf2'
main.c:(.text+0x650): undefined reference to `__adddf3'
main.c:(.text+0x65c): undefined reference to `__truncdfsf2'
main.c:(.text+0x66c): undefined reference to `__extendsfdf2'
main.c:(.text+0x680): undefined reference to `__adddf3'
main.c:(.text+0x68c): undefined reference to `__truncdfsf2'
main.c:(.text+0x698): undefined reference to `__extendsfdf2'
main.c:(.text+0x6ac): undefined reference to `__adddf3'
main.c:(.text+0x6b8): undefined reference to `__truncdfsf2'
main.c:(.text+0x6c4): undefined reference to `__extendsfdf2'
main.c:(.text+0x6d8): undefined reference to `__adddf3'
main.c:(.text+0x6e4): undefined reference to `__truncdfsf2'
main.c:(.text+0x6f0): undefined reference to `__extendsfdf2'
main.c:(.text+0x704): undefined reference to `__adddf3'
main.c:(.text+0x710): undefined reference to `__truncdfsf2'
main.c:(.text+0x71c): undefined reference to `__extendsfdf2'
main.c:(.text+0x730): undefined reference to `__adddf3'
main.c:(.text+0x73c): undefined reference to `__truncdfsf2'
main.c:(.text+0x748): undefined reference to `__extendsfdf2'
main.c:(.text+0x75c): undefined reference to `__adddf3'
main.c:(.text+0x768): undefined reference to `__truncdfsf2'
main.c:(.text+0x774): undefined reference to `__extendsfdf2'
main.c:(.text+0x788): undefined reference to `__adddf3'
main.c:(.text+0x794): undefined reference to `__truncdfsf2'
main.c:(.text+0x7a0): undefined reference to `__extendsfdf2'
main.c:(.text+0x7b4): undefined reference to `__adddf3'
main.c:(.text+0x7c0): undefined reference to `__truncdfsf2'
main.c:(.text+0x8cc): undefined reference to `__extendsfdf2'
main.c:(.text+0x8e4): undefined reference to `__muldf3'
main.c:(.text+0x8fc): undefined reference to `__gedf2'
Cheers Insomniac197, I owe you one. Turns out I was missing one step when building ther eboot:
.Code:psp-fixup-imports hello.elf
Next step, get Insight GDB running (oboy).
Yahoo :D:D:D:D: the different outputs only had 1 problem, it was becuase i didnt put a closing } after the first possible output. after i did, i was able to have ANY output i wanted. :D Thanks :D
how do u make somthing move around the screen when u ue the d-pad
in the tiff sdk
thanks
psp-freak222 - You havent grasped hte programming concept yet. Ill let you figure it out but a little hint...
* You CAN display something via variables ( PrintFine ( x, y, 0x00000000, "hi" ); )
* You CAN change avariable via button in put ( if X is pressed, x+=1)
* you CAN put 2 and 2 together
@ Sethis
well u know this is not the first time man . :)
Try to allways check these things before posting.
OK im really new to C/C++ i started (20 mins ago) with Yeldarb tut so plz don't flame.How do you possition a print on the screen EX:
stuff here ....
Do i do it like in Lua?Code:#define printf pspDebugScreenPrintf
int main() {
pspDebugScreenInit();
SetupCallbacks();
printf("Hello Word Made by:ZereoX");
sceKernelSleepThread();
return 0;
}
printf(100,50,"Hello Word Made by:ZereoX");?
Look at the header file "pspdebug.h". That will give you all the information you need for displaying text on the PSP screen.
Head_54us so i do this
pspDebugScreenSetXY(int x, int y); and i set the x and y for any number then
EX: pspDebugScreenSetXY(int 100, int 10);
or im totaly off
more of pspDebugScreenSetXY(100, 100) but keep in mind that it is for character position not pixel position.
For example, try this:
pspDebugScreenSetXY( 1, 1 );
pspDebugScreenPrintf( "Hello World" );
ZeroX - The debug console uses character cells, your limits of having text on screen is 60 x 38. that means everything past the 60th character on that row is either carried down one line or just not shown, depends on situation and the string. Same with Y character cells. Anything past 38 either doesnt show or brings it to the top at character cell 0.
If you want to print something in the middle of the screen use this function i jsut through together:
Note, this requires you add:Code:void PrintCentered ( int y, char *string, unsigned long color )
{
pspDebugScreenSetXY ( 30-(strlen(string)/2), y);
pspDebugScreenSetTextColor ( color );
pspDebugScreenPrintf ( string );
}
#include <string.h>
To the top of your code. As for color, use the RGB macro in tutorial 5 of yeldarb's tutorials ;)