• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

Oh noes, another homebrew question!

Deathscreton

New Member
Okay peeps of MFM. Bare with me. I'm here saying one statement that your probably BASHED across the face and crouch countless times. I need help coding PSP homebrew. NOW WAIT! Before you mark me down as a mental patient whose too lazy to do anything themselves, I've done my googling and it never seemed to help. I just want to ask a few questions that'll kick me off in the correct direction. And maybe if your interested in what I have to say afterwards, you can stick around and help me out greatly. No, i'm not asking you to hold my hand, I'm asking your to help me guide my bike. Just hear me out for a few minutes. Don't worry, I'm not a complete idiot when it comes to this. Just a really newbish newb. (I already have CYGWIN installing. Everything is going according to plan. I have yet to fetch the psptoolchain.)

Okay, Question 1.
I learned about PSP hombrew coding from psp-programming.com,
But as we all see, It's pretty much hella out-dated. It's still stuck on 3.80M33-4. o_O Anyways, I like how they came across with teaching how to brew homebrew on the PSP with C. But I don't want to use C. I need C++. Much more versatile. Anyways, my question to you is, What exact difference would there be between coding C and C++ for the PSP?

Question 2.
I know most don't like helping out the young'ns with coding, So i've commited myself to helping those with PSP homebrew as well..Once i learn how to do this shiz myself. I've notice that there aren't a lot of 3D homebrew games out there. I want to learn how to do this, that way I can pass it on for generations to come. So my second question to you is, How would I implement 3D graphics using OpenGL?

Now, I have plenty more questions to ask, but I don't want to waste my time typing if I'm going to have to vacate the board because It goes inactive because people don't feel like helping out fellow PSP coders in the homebrew community. Now why would I want to start coding so late into the PSP life? One good reason. PSPtube. We all know that both authors have let this poor HB die out. They have there own reasons. And a lot of people complaining and bitch about how they let them down. I was one of those people..Partially. But what makes me different, Is that I want to actually do something about it. They want to quit? I'll take up where they stopped. Not only PSPtube as me locked in, I have a dream of having a MMORPG with an excellent team and staff backing each other up as we come out with the most expansive PSP HB ever created..But to come to this dream, I have to have a starting place. And I need a guru/sensi/teacher. Anyone care to help out?
 

AndrewYY

New Member
Bare with me.
lol

AFAIK, there's nothing very special about programming for the PSP apart from the selection of functions you import, say, refreshing or drawing to the screen. Whatever language you know will work the way it works on any other platform, the only difference being the libraries you include.

Now I wait for somebody who actually knows their stuff to pwn me :p

By the way, for the sake of backwards compatibility, I should think the same programs written for version 3.80M33-4 will run on the latest firmwares.
 

Hellcat

Contributor
Hi there :)


For your questions:

1)
You can use C as well as C++, no problem, whatever you like more, GCC will handle both :)
The only difference would be you writing OOP code instead of "plain" code.... well, you get my point ;) There is no difference besides the way you write your code.

2)
Yah, not much 3D stuff, I wondered myself.
I can't help you with OpenGL (PSPGL is the OpenGL port for the PSP) as I don't use it, I use the native GU functions of the PSP directely.
3D and GFX in general are surprisingly easy to do on the PSP once you understood the basics and know the small traps that are around.
A quite good lecture (even though it keeps some things uncovered, but it's a start) are the GU samples of the (HB) PSPSDK.


:)
 

Deathscreton

New Member
2)
Yah, not much 3D stuff, I wondered myself.
I can't help you with OpenGL (PSPGL is the OpenGL port for the PSP) as I don't use it, I use the native GU functions of the PSP directely.
3D and GFX in general are surprisingly easy to do on the PSP once you understood the basics and know the small traps that are around.
A quite good lecture (even though it keeps some things uncovered, but it's a start) are the GU samples of the (HB) PSPSDK.


:)

Okay, with the PSPSDK, i'll be downloading that via CYGWIN and PSPTOOLCHAIN. If I wanted those lectures, I'd have to go download them manually correct? I think I might use the PSP's GU instead of taking alot of time trying to understand open GL. Unless there is loss between the two.

Whatever language you know will work the way it works on any other platform, the only difference being the libraries you include.

So I really don't need to go through the entire process of learning C++ if I already know C. The only thing is, that most of the Tutorials I find spread out on the web are C++ related...I think i'll just kill the old habit of being lazy and go for C++ anyways.
 

Deathscreton

New Member
Alright, I finally got my enviorment set up. Toolchain and Cygwin running perfectly..But now i've run into a few problems. I've got a tutorial for the PSP set up in front of me. But it using C as a language to code with. But i'm trying to learn C++. Now taking what I know from C++, I try to port the code from C to said language. This is the response I get from Cygwin.

Code:
$ make
psp-g++ -I. -I/cygdrive/c/cygwin/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall
-I. -I/cygdrive/c/cygwin/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exc
eptions -fno-rtti   -c -o main.o main.cpp
main.cpp:13:13: warning: missing whitespace after the macro name
main.cpp: In function 'int main()':
main.cpp:49: error: expected primary-expression before '<<' token
make: *** [main.o] Error 1

This is what is in my main.cpp source code

Code:
#include <pspkernel.h>
#include <pspdebug.h>

PSP_MODULE_INFO("Hello World",0,1,1);

#define cout<< 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(); 

cout<<"Hello World";
sceKernelSleepThread();
return 0;
}

Note, I didn't add <iostream> because I don't possibly see how Cyg could access that file from where it is located. But I did however, add it to the file once to see if the output would be any different...And It was not. Someone wanna help me out here?
 

AndrewYY

New Member
I have no idea how to program in c++, but replacing line 49 with pspDebugScreenPrintf("Hello World"); would fix ... I think
 

Deathscreton

New Member
I have no idea how to program in c++, but replacing line 49 with pspDebugScreenPrintf("Hello World"); would fix ... I think

Yes, that would solve my problem, But then that would defeat the purpose of me wanting to code in C++ or C for that matter. :/ And I think I know what the problem is. I have to link an extra library to the make file in order for C++ to work. That library being iostream.h. However, I don't know how to do that. I've opened up the Makefile but I see nothing that appears to look like anything to do with libraries.
 

Hardrive

Contributor
That's not the way to use cout, and you haven't really changed anything from C to C++ (you haven't linked in any C++ things or used any C++ headers). For now, just try to get something compiled, don't change the tutorials.

Judging by your code, it seems that you are not very experienced in programming. Correct me if I'm wrong. Under this assumption, I'd suggest that you scrap the PSP for now. Learn coding on the PC first. Grab yourself a good book. "Accelerated C++" is a great book for beginners. It may seem counter-productive, but you'll thank me for it later. The tutorials can't teach a inexperienced programmer enough to code for themself.

When you're learning, you need to test and compile a lot more to learn what you're doing. On the PC, this is as easy as pressing a button. However, on the PSP, you first have to compile it, and then you have to connect your PSP, copy it over, and then hope it runs. If it doesn't, you don't have a reliable means of output to do debugging. I'm sure any experienced developer would back me up in saying this.

For the record, I do not believe that input and output streams work on the PSP. To test this, you need to "#include <iostream>" in your main.cpp, remove that #define line, and add "-lstdc++" to the LIBS line in your makefile.

If you want a reference for a working C++ PSP program, you can download the Pong game (and source) that I made more than a year ago. There are a few unfixed memory leaks, but it can at least give you a step in the right direction. It is only in 2D because 3D is very complicated (IMO). Download link is here
 

Hellcat

Contributor
Your problem is the "cout" thing, doesn't really have anything to do with C/C++ differences.

cout outputs to the current stamdart output device, this only works on the PC as the PSP doesn't have a console (window) where it spits out stuff.

Always keep in mind you're not on the PC! Don't try to run PC based samples on the PSP, it'll fail.


// EDIT

HDD was faster :D
 

Deathscreton

New Member
That's not the way to use cout, and you haven't really changed anything from C to C++ (you haven't linked in any C++ things or used any C++ headers). For now, just try to get something compiled, don't change the tutorials.

Judging by your code, it seems that you are not very experienced in programming. Correct me if I'm wrong. Under this assumption, I'd suggest that you scrap the PSP for now. Learn coding on the PC first. Grab yourself a good book. "Accelerated C++" is a great book for beginners. It may seem counter-productive, but you'll thank me for it later. The tutorials can't teach a inexperienced programmer enough to code for themself.

When you're learning, you need to test and compile a lot more to learn what you're doing. On the PC, this is as easy as pressing a button. However, on the PSP, you first have to compile it, and then you have to connect your PSP, copy it over, and then hope it runs. If it doesn't, you don't have a reliable means of output to do debugging. I'm sure any experienced developer would back me up in saying this.

And I do think you are correct. The book cost money, and unfortunetly, that is a resource I have no access to at the moment. So I'm going to have someone help me one on one with my situation. He's also a programmer for both the PSP and PC and has more than a few years under his belt. With his knowledge and some tutorials from the internet, I'm sure this can benefit me more than a book. And If I happen to come across an opportunity, then I will try to pick up a book and look through it. All I want to do right about now is learn....Of course, this all depends on if he'll help me or not. :/ Otherwise, I'm on my ass again in the dumps.
 

Hardrive

Contributor
And I do think you are correct. The book cost money, and unfortunetly, that is a resource I have no access to at the moment. So I'm going to have someone help me one on one with my situation. He's also a programmer for both the PSP and PC and has more than a few years under his belt. With his knowledge and some tutorials from the internet, I'm sure this can benefit me more than a book. And If I happen to come across an opportunity, then I will try to pick up a book and look through it. All I want to do right about now is learn....Of course, this all depends on if he'll help me or not. :/ Otherwise, I'm on my ass again in the dumps.

If you can't bring yourself to invest in that book, why not download a free one? Bruce Eckel offers an electronic copy of his book, "Thinking in C++" available for free. This is also a quality book, you can get it in stores and everything.

For some reason, that portion of his site is down, so here is a mirror of them. Read Volume 1 first, of course ;)
 

Hardrive

Contributor
Awesome!! Much apprechiated! :D

No problem.

Just remember to start small. You're not going to jump straight into 3D. That would be like writing a novel in a foreign language that you only know the alphabet of.

You'll do fine though, you seem to be able to do searches for yourself and are able to listen to others unlike some new "developers" :)
 

Deathscreton

New Member
No problem.

Just remember to start small. You're not going to jump straight into 3D. That would be like writing a novel in a foreign language that you only know the alphabet of.

You'll do fine though, you seem to be able to do searches for yourself and are able to listen to others unlike some new "developers" :)

XD Understandable. This book is quite the confusing one though. I've gone through chapter 2 twice...I see the writing as more of a reference than a step into C++. Know what I mean? I'm not giving up, don't get me wrong, but it's going to take me a lot longer than I expected. The person that was supposed to help me learn as well has been too busy to do much of anything but work. D: So I'm on my own again. But anyways, that book is more of a intermediate type. I need to understand C++ basics before I understand anything the Book is talking about...
 

Hardrive

Contributor
XD Understandable. This book is quite the confusing one though. I've gone through chapter 2 twice...I see the writing as more of a reference than a step into C++. Know what I mean? I'm not giving up, don't get me wrong, but it's going to take me a lot longer than I expected. The person that was supposed to help me learn as well has been too busy to do much of anything but work. D: So I'm on my own again. But anyways, that book is more of a intermediate type. I need to understand C++ basics before I understand anything the Book is talking about...

If I remember correctly, one of the beginning chapters starts relatively quickly. It may help to read some intro C++ tutorials and get some compiling and syntax practice under your belt before going through the book.
 

Cryox

Bro.
If you use any torrent sites, you can for sure get Accelerated C++ from their, and then buy the book when you have the money to do so.

Demonoid or TPB probably have it.
 

Deathscreton

New Member
If you use any torrent sites, you can for sure get Accelerated C++ from their, and then buy the book when you have the money to do so.

Demonoid or TPB probably have it.

TPB is being bought out sadly. D: And i've got those sites listed above this guy's post bookmarked already. I've been studying for awhile and hopefully, i'll be able to continue with the book.
 
Top