psp c++ dev.

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

Moderators: cheriff, TyRaNiD

xlordt
Posts: 6
Joined: Tue May 27, 2008 3:27 pm

psp c++ dev.

Post by xlordt »

Hi guys, can anyone help me out on some c++ tutorials... I found and read a few tutorials... but most of them are in c.. this is what I have so far, as you can see I am new to this psp stuff as well..

Code: Select all


#include <iostream>
#include <pspkernel.h>
#include <pspdebug.h>

#define printf pspDebugScreenPrintf

using namespace std;

PSP_MODULE_INFO&#40;"Hello World", 0, 1, 1&#41;;


 /* 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;;
 
     cout << "testing baby";
        
     return 0;
&#125;
hmm looks like all I need is a c++ make file.. anyone has a basic one?
Tinnus
Posts: 67
Joined: Sat Jul 29, 2006 1:12 am

Post by Tinnus »

You can use a C make file for C++ programs. Also, eveything in your code is pretty much C, not C++ specifically, except for the cout stuff which BTW I don't think will work :P
Let's see what the PSP reserves... well, I'd say anything is better than Palm OS.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

cout does work with a fully updated toolchain and psplink, but it adds something silly like 300k to your binaries, not recommended :P
Crux
Posts: 10
Joined: Sun May 25, 2008 1:46 pm

Post by Crux »

So if we define this...

Code: Select all

#define printf pspDebugScreenPrintf
We use this...

Code: Select all

cout
Hmm... Maybe we should try

Code: Select all

printf&#40;"Hello, world!"&#41;; or pspDebugScreenPrintf&#40;"Hello, world!"&#41;;
Just a thought ^_^
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

but it adds something silly like 300k
Some time ago Linus Torvalds said that "Inheritance, polymorphism and C++ features in general are something no one needs". Beast. It's the only thing I and one of my ex teachers think about these words. In my country a 2 Gb SD memory card costs about 6 euros: who cares about 300k when the payback is code readability (and mantainability), reusability and a more logical flow in general? Poor speed performances are not a direct consequence of polymporphism or exception mechanism, too...it's only that you got to know how to use it like everything on this world.
xlordt
Posts: 6
Joined: Tue May 27, 2008 3:27 pm

Post by xlordt »

ahh damn you are right.... been a long day will try it out. so I can change that to use cout instead of printf.


Crux wrote:So if we define this...

Code: Select all

#define printf pspDebugScreenPrintf
We use this...

Code: Select all

cout
Hmm... Maybe we should try

Code: Select all

printf&#40;"Hello, world!"&#41;; or pspDebugScreenPrintf&#40;"Hello, world!"&#41;;
Just a thought ^_^
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

jean wrote:In my country a 2 Gb SD memory card costs about 6 euros: who cares about 300k
Regardless of your SD cards, the PSP still has limited RAM for applications.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

jean wrote:
but it adds something silly like 300k
Some time ago Linus Torvalds said that "Inheritance, polymorphism and C++ features in general are something no one needs". Beast. It's the only thing I and one of my ex teachers think about these words. In my country a 2 Gb SD memory card costs about 6 euros: who cares about 300k when the payback is code readability (and mantainability), reusability and a more logical flow in general? Poor speed performances are not a direct consequence of polymporphism or exception mechanism, too...it's only that you got to know how to use it like everything on this world.
Sorry, but I'm one of those people who sees NOTHING of any worth in C++. It's a worthless waste of a language that I refuse to use myself. I don't care for working on projects that are in C++ unless I have to. Fewer lines does not mean "readability" or "more logical flow". In fact, C++ programs that actually USE C++ are rarely readable at all, and certainly nowhere near as readable as a similiarly complex C program.

No, it's CLEAR that the only reason for using C++ is to make the program LESS readable with LESS logical flow so as to make the programmer indispensable to the project. It's nothing more than trying to artificially maintain job security.
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

C++ less readable and less logical than C ....well I prefer read this than being blind..even though .... ;-)))


But it's the kind of thread that never ends and not really PSP related isn't it?
--pspZorba--
NO to K1.5 !
xlordt
Posts: 6
Joined: Tue May 27, 2008 3:27 pm

Post by xlordt »

Tinnus wrote:You can use a C make file for C++ programs. Also, eveything in your code is pretty much C, not C++ specifically, except for the cout stuff which BTW I don't think will work :P
Ok I just want to figure this out.. is there any c++ psp tutorials that I can look at?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

jean, sure you get a 2gb SD card but remember the PSP only has 24 megs of ram, that is 300KB wasted on in effect debug output :)
xlordt
Posts: 6
Joined: Tue May 27, 2008 3:27 pm

Post by xlordt »

ok.. I think I got it working.. so far I got my EBOOT file compiled, now I have one more question.. do I just need to take a eboot file and put it in the psp? and that is all????
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

but remember the PSP only has 24 megs of ram
Ok....this seems reasonable. Anyhow it seems to me that -lstdc++ lib is something you add once and for all...i mean: you don't have relevant growth for each c++ feature you're going to use...am i wrong?
@JF:
I was of your same advice when i knew quite NOTHING about OOP. Now i'm fond of it.....Do you hate c++ so bad because a class bited you when you was a child? lol
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

I think it's like for all other libs, GCC will "take" what it needs and only what it needs from the libs. So if you use an other "feature" from stdc++ you will increase the size of you eboot.

I guess that the increase of 300kb comes from the fact that cout implied that you will include all iostream features.

Meaning if you want to use file C++ management functions you won't increase the size of your Eboot, so yes 300kb is pretty big for just an "hello new world" program, but probably for a program more complex the difference won't be so big.
--pspZorba--
NO to K1.5 !
xlordt
Posts: 6
Joined: Tue May 27, 2008 3:27 pm

Post by xlordt »

Yes... that is why I am not stressing it, in time the program will be bigger.. planning on creating a psp transfer program.. were you can transfer files from psp to psp.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

jean wrote:@JF:
I was of your same advice when i knew quite NOTHING about OOP. Now i'm fond of it.....Do you hate c++ so bad because a class bited you when you was a child? lol
I know all about OOP, and there are far better OOP languages out. C++ truly sucks in that respect. Even Obj-C is better. I think Apple had that one point right when they moved from C to Obj-C. Personally, I think Ada is far better than C++. I also cut my teeth on SmallTalk, a very cool OOP language.
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

J.F. : i do agree that C+ is not the best OOP language, I loved smalltalk (ada is good too) and moreover all : Eiffel is probably the best OOP language. But unfortunately we just have C++ on the PSP.

xlordt:
ok.. I think I got it working.. so far I got my EBOOT file compiled, now I have one more question.. do I just need to take a eboot file and put it in the psp? and that is all????
Yes copy it under /psp/game/nameOfMyHB/
--pspZorba--
NO to K1.5 !
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Not really wanting to continue this C++ flaming but tbh if you don't understand why C++ is like it is and why it probably shouldn't be truly classified as an OO language then you probably to stay using minority languages, hehe ;)

C++ rocks for what it needs to do, which is fast data/code encapsulation and type safety improvements over C. All the extra OO crap they have added over the years have just made it worse.
capz
Posts: 6
Joined: Tue May 20, 2008 4:15 am

Post by capz »

this thread makes most of the people inside sound like a bunch of little kids, come on people!

@xlordt; so C++ is working for you now?
xlordt
Posts: 6
Joined: Tue May 27, 2008 3:27 pm

Post by xlordt »

capz wrote: @xlordt; so C++ is working for you now?
Yes thanx :)
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

All the extra OO crap they have added over the years have just made it worse.
...but made my happiness when i wanted to port a project of mine originally written in java so it can be executed on a psp (or where the hell i like)....and without that stupid code management!! Seriously dudes: i see you are kings of low-level (and i like it, too), but you have to admit that you can't fully rewrite your favourite operating system in asm. A lot of people like only to play games where they win...
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

jean wrote:
All the extra OO crap they have added over the years have just made it worse.
...but made my happiness when i wanted to port a project of mine originally written in java so it can be executed on a psp (or where the hell i like)....and without that stupid code management!! Seriously dudes: i see you are kings of low-level (and i like it, too), but you have to admit that you can't fully rewrite your favourite operating system in asm. A lot of people like only to play games where they win...
to add some wood into the flames, the PSP kernel has been made mostly in C, and the VSH is mostly C++ :)
SilverSpring
Posts: 110
Joined: Tue Feb 27, 2007 9:43 pm
Contact:

Post by SilverSpring »

adrahil wrote:
jean wrote:
All the extra OO crap they have added over the years have just made it worse.
...but made my happiness when i wanted to port a project of mine originally written in java so it can be executed on a psp (or where the hell i like)....and without that stupid code management!! Seriously dudes: i see you are kings of low-level (and i like it, too), but you have to admit that you can't fully rewrite your favourite operating system in asm. A lot of people like only to play games where they win...
to add some wood into the flames, the PSP kernel has been made mostly in C, and the VSH is mostly C++ :)
and a bit of asm too :)
Tinnus
Posts: 67
Joined: Sat Jul 29, 2006 1:12 am

Post by Tinnus »

Geez, I wouldn't think anyone in their right mind would write something intrinsically as modular as the PSP VSH without OO :P
Let's see what the PSP reserves... well, I'd say anything is better than Palm OS.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Tinnus wrote:Geez, I wouldn't think anyone in their right mind would write something intrinsically as modular as the PSP VSH without OO :P
Modular has NOTHING WHATSOEVER to do with the language the module is programmed in. People were doing "modular" programming long before OO languages became vogue. Modern computer classes are brainwashing mediocre programmers into the idea that modular == OO. And don't try to claim it makes it "easier" as that is merely one person's opinion. My own is that I've never seen a module that was "easier" to write in C++ than in C.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

J.F, I don't understand your flame about C++ : people are free to use the language they like. As long as this is a choice, there is no reason to be intolerant about C++. It may not be perfect per se, but I'm glad to have it for some projects where C would be ugly or evil (C prepocessor really sucks in many aspect and virtualization is hell in C). So, please, let us stop this futile talk about C++ and be all friends !
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Hey, everyone is free to use whatever language they want. If someone wishes to use C++, more power to 'em. But don't try to tell me that C++ is the Language Of God Made Manifest when it clearly isn't. My "rant" is just me providing balance to all the praises heaped on C++ in the thread. Like that remark by Tinnus that modular HAS to be C++. Such inaccuracies must be corrected.

I'm not being unfriendly, just making sure that people aren't unduly influenced into thinking C++ is the Second Coming. Don't try to blow smoke up my @ss and I won't rant any more. :)

The purpose of this thread was achieved long ago, and all that remains now is just people trying to make points for or against C++. It should be locked.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

lock my....no, no sorry i didn't mean to.. oh c'mon, WHY you have to be always so intolerant? Apart from my first encounter with you here, i remember you even corrected someone trying to say a bullshit to do an april's fool!! Please....smile to life!!
PS: maybe if you start more of your phrases with "i modestly think..." people would have more respect for you and you'll not need to always "shout". Honestly, if not for my knowledge, i would keep my position because of your "balancing" rant.
PPS: in case someone missed it, this is a FORUM, where people meet to TALK. I modestly think that rules are made only to avoid personal offences that could take to legal actions and, in general to make the site more comfortable. As long as people are interested in the argument they speak of and as long as they argument nicely, there's nothing wrong in it....don't go crying on mom's shoulder if you can't be the first lady as you wish to.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

oo, drama! love it!
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

It's funny how since I don't think C++ is "teh bomb" I'm the bad guy here. People can make broad statements of praise, but the moment I point out that many people think it's flawed, I'm somehow "ranting". Sheesh!

When I point out that all I'm doing is trying to provide the other side of the argument on C++, now I'm being "intolerant". First off, that's not even correct by definition. I TOLERATE C++ users. I don't approve of them. It's very different. People have forgotten what tolerate means because of the PC idiots in society today. I even said in the thread that you can use C++ if you want, only that I don't use it unless I'm absolutely have to. Sounds tolerant to me.
Post Reply