Ah I see, thanks a lot :tup:Zitat:
Zitat von Propel
So what files do the C coding end up to be, and can you test them on your computer before they go on the PSP?
Printable View
Ah I see, thanks a lot :tup:Zitat:
Zitat von Propel
So what files do the C coding end up to be, and can you test them on your computer before they go on the PSP?
When you compile them, they come out as EBOOTS, for regular homebrew, or sometimes PRXs, or a .BIN file for TIFF homebrew. And you can only test them if you have a mac, or a mac emulator. Then you can use the program by xart.Zitat:
Zitat von ZeroMega
Oh no, I don't have a Mac. >_<;Zitat:
Zitat von Propel
Thanks though
Neither do I, that's why I'm setting up a Mac OS 8 Emulator. I manged to get Mac OS X on my laptop, but it's not booting right.Zitat:
Zitat von ZeroMega
Okay I used a lib that Grimfate made for me on AIM and I tried to match it for my game but it still doesnt shoot:
Spoiler for Lib:
Spoiler for Main.Cpp:
still not fixedZitat:
Zitat von hallo007
Here's a quick n' dirty one. In sceKernelCreateThread, is the stack size variable in KB or B or what?
Thanks.
jait - bytes. (80% sure)
I was trying to write a program in which it displays hello world, and then loops until i press cross [X]. then i came to 1 piece of code in which i did not exactly understand it is this one
can anyone explain to me what this means? thanksCode:
SetupCallbacks ();
edit - also what it does, thanks
That's most likely referring to the exit callbacks. It's a chunk of code about 10 - 12 lines long, that allows your PSP's 'HOME' button to work when running the game.Zitat:
Zitat von Sethis
I know which code your talkin about. but when i tried out the hello world program with that code....the home button didnt work lol...
Post your code and Makefile.Zitat:
Zitat von Sethis
dont have a make file yet xD and im sure EVERYTHING is wrong there xD.....im a total newb so please hang in for me lol... tahnksCode:
//random program
//thanks to psp-programming.com for exit callback code.
#include <pspkernel.h>
#include <pspdebug.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO ("Hello World Display Until button pressed and cleared.", 0, 1, 1);
int main() {
SetupCallBacks ();
pspDebugScreenInit ();
printf("Hello World \n\n");
printf("Press [X] to clear screen.");
while(1){
//i dont know what the code is to clear screen when button is pressed can anyone help i left a blank line
//i think thats where it goes...is it pspDebugScreenClear or sce....what does sce mean?
____________________________;
if( pad.Buttons &PSP_CTRL_CROSS){
break;
}
}
sceKernalSleepThread ();
/* 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;
}
I quickly wrote that up. It should suffice...Code:#include <pspkernel.h>
#include <pspdebug.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO ("Hello World Display Until button pressed and cleared.", 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 ();
printf("Hello World \n\n");
printf("Press [X] to clear screen.");
SceCtrlData pad;
while(1){
sceCtrlPeekBufferPositive(&pad,1);
if( pad.Buttons & PSP_CTRL_CROSS){
pspDebugScreenClear();
}
}
return 0;
}
wait dont i need to innclude another protocol....i forgot which one it was called but it was like ctrl or something
#include <pspctrl.h>
was it. i cant remember i think i need that right? becuase it needs that to click stuff like the [x]
Thanks :D SG57 and all that took the time to help :D
Ya, my bad. Totally space on default libraries like that since everything i do make automatically has all the psp____ libraries... So ya, just add pspctrl.h to the top in an include statement and it should work.
Anyone gonna get to this?Zitat:
Zitat von Gonrai
Gonrai - Bullet shooting isnt as difficult as you make it out to be. hell I did it 2 times using ASCII characters. I used a structure like:
If you think logically and strategically about it, youll get it. That should get you off to the right foot... (than again, you ARE pretty new to C :-\ maybe should have given u more)Code:typedef struct bullet {
int x,y,onScreen;
} bullet;
bullet[#_of_bullets_total];
this crashes my psp
Code:#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include <psploadexec.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("Hello World", 0, 1, 1);
PSP_MAIN_THREAD_ATTR (0);//zeg de psp dat het programma kernel acces nodig heeft
/* 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 load_Eboot_calculator(void)
{
struct SceKernelLoadExecParam calculator;
char *path_calculator= "ms0:/PSP/GAME/HELLOWORLD/EBOOT.PBP"; /*geheugenplaats voor de naam van de eboot die je wilt laden*/
const u32 Length_of_Eboot = strlen(path_calculator )+1;
pspDebugInstallKprintfHandler (NULL);
pspDebugInstallErrorHandler (NULL);
calculator.args = Length_of_Eboot;
calculator.argp = path_calculator;
calculator.key = NULL;
calculator.size = sizeof(calculator)+Length_of_Eboot;
sceKernelLoadExec(path_calculator,&calculator);
}
int main()
{
pspDebugScreenInit();
SetupCallbacks();
printf("press cross to load calculator");
SceCtrlData pad;
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS){
load_Eboot_calculator();
}
}
Hey SG57 I was lookin over the code that you quicky wipped up, and i couldnt see sceSleepKernelThread ();
I remember it was for something like pausing the program from exiting itself. Do i need that in my code? Thanks
Off topic: a couple days ago i saw this great sig but forgot who wrote in their sig. it was
there is 10 types of ppl in the world, ppl who can read binary, and those who can't. at first im wonder wtf, and as i thought about it more i was like WOW GENIUS lol.
00 - 0
01 - 1
10 - 2
i just know the basics but this was an awesome joke. Great Sig :D whoever it was lol.
SG57,
Thanks. Much appreciated.
I have two questions,
what does >> and << do?
and what does % do? (like, rand() % (Max+Min))
<< and >> are bit shift operators.
http://www.phim.unibe.ch/comp_doc/c_...T/bitwise.html
% is modulus
http://www.cprogramming.com/tutorial/modulus.html
>> right shift (move bits in source to the right, filling in with 0's by the amount of the right side, ie. 01011 >> 1 = 00101)
<< left shift (same as above, only move left, ie 01011 << 1 = 10110)
Shifts are basically a mutiplication (left shift) or division (right shift) by 2^n, ie shift by 1 is same as mul/div 2, shift by 2 is same as mul/div by 4, etc.
% modulo (modulo as known from basic maths. 5 % 2 = 1, 2 % 3 = 2, etc.)
Modulo is the rest you get when dividing the 2 numbers. Like
9%3, 9/3 = 3 so the rest is 0.
not fixed yetZitat:
Zitat von hallo007
If you leave it long enough, it might magically fix itself.Zitat:
Zitat von hallo007
You're going to get no help without posting any errors, or exactly what your problem is. Your attitude leaves a lot to be desired.
Hallo007, this should work.
main.c
makefileCode:#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#define calculator_path "ms0:/PSP/GAME/HELLOWORLD/EBOOT.PBP"
#define printf pspDebugScreenPrintf
PSP_MODULE_INFO("Hello World", 0x1000, 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;
}
void load_Eboot_calculator(void)
{
struct SceKernelLoadExecParam param;
memset(¶m, 0, sizeof(param));
param.size = sizeof(param);
param.args = strlen(calculator_path);
param.argp = calculator_path;
param.key = NULL;
sceKernelLoadExec(calculator_path,¶m);
}
int main()
{
pspDebugScreenInit();
SetupCallbacks();
pspDebugInstallKprintfHandler (NULL);
pspDebugInstallErrorHandler (NULL);
printf("Press cross to load calculator");
SceCtrlData pad;
while(1) {
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
load_Eboot_calculator();
}
}
sceKernelExitGame();
return 0;
}
this should work although i havn't tested it.Code:TARGET = calc
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Calculator Test
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
A few questions, but first my code.
Now for my questionsCode:int main() {
SetupCallBacks ();
pspDebugScreenInit ();
pspDebugScreenPrinntf("Hello World \n\n Press [X] to clear screen.");
sceCtrlData pad;
sceKernelSleepThread ();
while (1) {
sceCtrolPeekBufferPositive(&pad, 1);
if (pad.Buttons &PSP_CTRL_CROSS) {
pspDebugScreenClear ();
}
}
return 0;
}
1. In the "while" loop there has to be a break;. Is pspDebugScreenClear (); going to make that break happen at the same time clear the screen?
2. When the loops are applied, what part of the code will it loop around? For example in the above code. Will it loop only around that? Or will it loop around all of the main function.Code:while (1) {
sceCtrolPeekBufferPositive(&pad, 1);
if (pad.Buttons &PSP_CTRL_CROSS) {
pspDebugScreenClear ();
3. In my main function, before the loop is "sceKernelSleepThread ();" needed? I understand that it keeps the program from exiting but when i was going through some code that was edited before i didnt see it, or i missed it.
3. I was looking at lesson 3 at www.psp-programming.com. They were talking about counters, and there were multiple loops. I only saw one with this code "sceCtrlReadBufferPositiv e(&pad, 1);" then in a couple earlier posts i posted another code in which i tried to make the printed Hello World disappear with the push of a button. In that code i realized the loop was different it had this code "sceCtrlPeekBufferPositiv e(&pad, 1);" What are the differences?
4. What does the term sce mean?
5. does "sceCtrlData pad;" tell the psp to get ready for some sort of input through the key pad like [X] [O] [ ] [^]?
I think that is most of em, but I will probably have more sooner or later.
Thanks for all your help :D
Seth
1.) There doesn;t have to be a break, the point of doing while(1) is to have a infinite loop.
2.) All loops execute the code in the following opening and closing brackets {...}
3.) The second one is found to be faster, that's all...
4.)sce stands for Sony Computer Entertainment (if you look at Sony's official leaked library, you will see each function is identical, so this probably copied the names from sony)
5.) Yes, sceCtrlData is a data type (struct) and pad is the variable it's declaring... so you could do this insteadCode:sceCtrlData foo;
if( foo.Buttons && PSP_CTRL_CROSS ) {
//blah
}
Btw, the first code you posted won't work ;)
when you were refering to my earlier code. Did you mean the one where i displayed hello world, and then press X to clearscreen? or the counter? the counter is all messed right now and i scrapped it i decided to stick to a simpe hello world at first and slowly expanding on it.
i have another question. how would i implement a secondary function? int main (); is a primary function whats a secondary one? Thanks for the quick response Bronx
Slight correction, main () is the default entry point of the program.Zitat:
Zitat von Sethis
Functions: http://www.cprogramming.com/tutorial/c/lesson4.html
Thanks :D
EDIT: forget the stuff that was here, i ran into a few more problems
here is my main function
here is my cygwin outputCode:int main();
SetupCallBacks();
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;
}
$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
main.c:38: warning: type defaults to 'int' in declaration of 'SetupCallBacks'
main.c:38: warning: data definition has no type or storage class
main.c:40: error: syntax error before string constant
main.c:40: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:40: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:49: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:40: warning: data definition has no type or storage class
main.c:41: error: syntax error before 'pad'
main.c:41: warning: type defaults to 'int' in declaration of 'pad'
main.c:41: warning: data definition has no type or storage class
make: *** [main.o] Error 1
please help lol thanks :D
Once you have the \n you can't have more text after it, you need a new printing statement
.....now i didnt know that so it would look like this
[CODE]
printf ("hello \n");
printf ("line 2 \n");
printf ("is this right?");
hmmm your really noooooob my friend PUT A ; at the end
Yes you can, it must be an error somewhere else.Zitat:
Zitat von Bronx
unique warrior - it was typing error. also i am 13 years old.... i am aware that the compiler will not see any white space so ; is needed.
will - im lost.
in my last post i posted my CYGWIN output also my code main function, if anyone could take a look at that and see whats wrong, it would be great thanks :D
pspDebugScreenInit();
put it in first I'm reading your code :)
found it ... remove this from the first lines of your program
#defien printf pspDebugScreenprintf();
and there is no space pspDebugScreenPrintf"ther e is no space here"();
at first the cygwinn was saying that pspDebugScreenInit was causing a problem so i removed it lol... and ill try removing that now.
edit: same errors heres what i get
$ make kxploit
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o mai
n.c
main.c:38: warning: type defaults to 'int' in declaration of 'SetupCallBacks'
main.c:38: warning: data definition has no type or storage class
main.c:39: warning: type defaults to 'int' in declaration of 'pspDebugScreenInit
'
main.c:39: error: conflicting types for 'pspDebugScreenInit'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:32: error: previous declaration of
'pspDebugScreenInit' was here
main.c:39: warning: data definition has no type or storage class
main.c:40: error: syntax error before string constant
main.c:40: warning: type defaults to 'int' in declaration of 'pspDebugScreenPrin
tf'
main.c:40: error: conflicting types for 'pspDebugScreenPrintf'
/usr/local/pspdev/psp/sdk/include/pspdebug.h:49: error: previous declaration of
'pspDebugScreenPrintf' was here
main.c:40: warning: data definition has no type or storage class
main.c:41: error: syntax error before 'pad'
main.c:41: warning: type defaults to 'int' in declaration of 'pad'
main.c:41: warning: data definition has no type or storage class
make: *** [main.o] Error 1