forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

psp c++ dev.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
xlordt



Joined: 27 May 2008
Posts: 6

PostPosted: Fri May 30, 2008 1:33 am    Post subject: psp c++ dev. Reply with quote

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:


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

#define printf pspDebugScreenPrintf

using namespace std;

PSP_MODULE_INFO("Hello World", 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()
{
     pspDebugScreenInit(); 
     SetupCallbacks();
 
     cout << "testing baby";
       
     return 0;
}


hmm looks like all I need is a c++ make file.. anyone has a basic one?
Back to top
View user's profile Send private message
Tinnus



Joined: 29 Jul 2006
Posts: 67

PostPosted: Fri May 30, 2008 6:15 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri May 30, 2008 6:42 am    Post subject: Reply with quote

cout does work with a fully updated toolchain and psplink, but it adds something silly like 300k to your binaries, not recommended :P
Back to top
View user's profile Send private message
Crux



Joined: 25 May 2008
Posts: 10

PostPosted: Fri May 30, 2008 9:24 am    Post subject: Reply with quote

So if we define this...

Code:
#define printf pspDebugScreenPrintf


We use this...

Code:
cout


Hmm... Maybe we should try

Code:
printf("Hello, world!"); or pspDebugScreenPrintf("Hello, world!");


Just a thought ^_^
Back to top
View user's profile Send private message
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Fri May 30, 2008 9:57 am    Post subject: Reply with quote

Quote:
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.
Back to top
View user's profile Send private message
xlordt



Joined: 27 May 2008
Posts: 6

PostPosted: Fri May 30, 2008 10:54 am    Post subject: Reply with quote

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:
#define printf pspDebugScreenPrintf


We use this...

Code:
cout


Hmm... Maybe we should try

Code:
printf("Hello, world!"); or pspDebugScreenPrintf("Hello, world!");


Just a thought ^_^
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Fri May 30, 2008 11:08 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri May 30, 2008 11:24 am    Post subject: Reply with quote

jean wrote:
Quote:
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.
Back to top
View user's profile Send private message AIM Address
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Fri May 30, 2008 12:28 pm    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
xlordt



Joined: 27 May 2008
Posts: 6

PostPosted: Fri May 30, 2008 2:48 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri May 30, 2008 3:37 pm    Post subject: Reply with quote

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 :)
Back to top
View user's profile Send private message
xlordt



Joined: 27 May 2008
Posts: 6

PostPosted: Fri May 30, 2008 4:03 pm    Post subject: Reply with quote

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????
Back to top
View user's profile Send private message
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Fri May 30, 2008 7:19 pm    Post subject: Reply with quote

Quote:
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
Back to top
View user's profile Send private message
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Fri May 30, 2008 9:11 pm    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
xlordt



Joined: 27 May 2008
Posts: 6

PostPosted: Fri May 30, 2008 10:56 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Fri May 30, 2008 11:04 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Fri May 30, 2008 11:35 pm    Post subject: Reply with quote

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:

Quote:
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 !
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat May 31, 2008 1:04 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
capz



Joined: 20 May 2008
Posts: 6

PostPosted: Sat May 31, 2008 6:39 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
xlordt



Joined: 27 May 2008
Posts: 6

PostPosted: Sun Jun 01, 2008 4:09 am    Post subject: Reply with quote

capz wrote:

@xlordt; so C++ is working for you now?
Yes thanx :)
Back to top
View user's profile Send private message
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Sun Jun 01, 2008 9:22 am    Post subject: Reply with quote

Quote:
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...
Back to top
View user's profile Send private message
adrahil



Joined: 16 Mar 2006
Posts: 277

PostPosted: Sun Jun 01, 2008 11:12 am    Post subject: Reply with quote

jean wrote:
Quote:
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++ :)
Back to top
View user's profile Send private message
SilverSpring



Joined: 27 Feb 2007
Posts: 115

PostPosted: Sun Jun 01, 2008 3:03 pm    Post subject: Reply with quote

adrahil wrote:
jean wrote:
Quote:
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 :)
Back to top
View user's profile Send private message Visit poster's website
Tinnus



Joined: 29 Jul 2006
Posts: 67

PostPosted: Mon Jun 02, 2008 2:14 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Jun 02, 2008 5:50 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Mon Jun 02, 2008 6:12 am    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Jun 02, 2008 7:01 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Mon Jun 02, 2008 8:41 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Mon Jun 02, 2008 10:44 pm    Post subject: Reply with quote

oo, drama! love it!
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Jun 02, 2008 11:49 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group