| View previous topic :: View next topic |
| Author |
Message |
xlordt
Joined: 27 May 2008 Posts: 6
|
Posted: Fri May 30, 2008 1:33 am Post subject: psp c++ dev. |
|
|
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 |
|
 |
Tinnus
Joined: 29 Jul 2006 Posts: 67
|
Posted: Fri May 30, 2008 6:15 am Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Fri May 30, 2008 6:42 am Post subject: |
|
|
| 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 |
|
 |
Crux
Joined: 25 May 2008 Posts: 10
|
Posted: Fri May 30, 2008 9:24 am Post subject: |
|
|
So if we define this...
| Code: | | #define printf pspDebugScreenPrintf |
We use this...
Hmm... Maybe we should try
| Code: | | printf("Hello, world!"); or pspDebugScreenPrintf("Hello, world!"); |
Just a thought ^_^ |
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Fri May 30, 2008 9:57 am Post subject: |
|
|
| 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 |
|
 |
xlordt
Joined: 27 May 2008 Posts: 6
|
Posted: Fri May 30, 2008 10:54 am Post subject: |
|
|
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...
Hmm... Maybe we should try
| Code: | | printf("Hello, world!"); or pspDebugScreenPrintf("Hello, world!"); |
Just a thought ^_^ |
|
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Fri May 30, 2008 11:08 am Post subject: |
|
|
| 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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri May 30, 2008 11:24 am Post subject: |
|
|
| 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 |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Fri May 30, 2008 12:28 pm Post subject: |
|
|
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 |
|
 |
xlordt
Joined: 27 May 2008 Posts: 6
|
Posted: Fri May 30, 2008 2:48 pm Post subject: |
|
|
| 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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Fri May 30, 2008 3:37 pm Post subject: |
|
|
| 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 |
|
 |
xlordt
Joined: 27 May 2008 Posts: 6
|
Posted: Fri May 30, 2008 4:03 pm Post subject: |
|
|
| 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 |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Fri May 30, 2008 7:19 pm Post subject: |
|
|
| 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 |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Fri May 30, 2008 9:11 pm Post subject: |
|
|
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 |
|
 |
xlordt
Joined: 27 May 2008 Posts: 6
|
Posted: Fri May 30, 2008 10:56 pm Post subject: |
|
|
| 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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri May 30, 2008 11:04 pm Post subject: |
|
|
| 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 |
|
 |
pspZorba
Joined: 22 Sep 2007 Posts: 156 Location: NY
|
Posted: Fri May 30, 2008 11:35 pm Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat May 31, 2008 1:04 am Post subject: |
|
|
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 |
|
 |
capz
Joined: 20 May 2008 Posts: 6
|
Posted: Sat May 31, 2008 6:39 am Post subject: |
|
|
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 |
|
 |
xlordt
Joined: 27 May 2008 Posts: 6
|
Posted: Sun Jun 01, 2008 4:09 am Post subject: |
|
|
| capz wrote: |
@xlordt; so C++ is working for you now? | Yes thanx :) |
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Sun Jun 01, 2008 9:22 am Post subject: |
|
|
| 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 |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Sun Jun 01, 2008 11:12 am Post subject: |
|
|
| 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 |
|
 |
SilverSpring
Joined: 27 Feb 2007 Posts: 115
|
Posted: Sun Jun 01, 2008 3:03 pm Post subject: |
|
|
| 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 |
|
 |
Tinnus
Joined: 29 Jul 2006 Posts: 67
|
Posted: Mon Jun 02, 2008 2:14 am Post subject: |
|
|
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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Jun 02, 2008 5:50 am Post subject: |
|
|
| 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 |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Mon Jun 02, 2008 6:12 am Post subject: |
|
|
| 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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Jun 02, 2008 7:01 am Post subject: |
|
|
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 |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Mon Jun 02, 2008 8:41 pm Post subject: |
|
|
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 |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Mon Jun 02, 2008 11:49 pm Post subject: |
|
|
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 |
|
 |
|