C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von yaustar Bad. You are initialising the random number generator every time you call GetRandom. This will give you ...
-
09-01-2008, 01:16 PM #9031QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Perth, Scotland
- Beiträge
- 1.094
- Points
- 8.475
- Level
- 62
- Downloads
- 0
- Uploads
- 0
My apologies.
That seems more accurate I think. I've not tested it yet, but, it should work.Code:void InitRandom(SceKernelUtilsMt19937Context *ctx) { u32 tick = sceKernelGetSystemTimeLow(); sceKernelUtilsMt19937Init(ctx, tick); } int GetRandom(int min, int max, SceKernelUtilsMt19937Context *ctx) { return (sceKernelUtilsMt19937UInt(ctx) % (max - min + 1)) + min; }
Alternatively, you can set the ctx as a global and modify it there.
-
09-01-2008, 03:08 PM #9032I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
-
09-01-2008, 05:40 PM #9033
- Registriert seit
- Apr 2008
- Beiträge
- 47
- Points
- 2.658
- Level
- 31
- Downloads
- 0
- Uploads
- 0
-
09-01-2008, 10:04 PM #9034QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- Netherlands
- Beiträge
- 148
- Points
- 5.672
- Level
- 48
- Downloads
- 0
- Uploads
- 0
I thought it was:
Code:int GetRandom(int upTo) { return rand() % upTo; }[SIZE="1"][color=#D1D1FF]______________________________________________________________[/color]
[i]Last edited by basfreak; 01-01-1990 at [color=#666686]12:00 PM[/color][/i].[/SIZE]
-
09-02-2008, 02:12 AM #9035QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
rand() is the Standard Library's random number generator. It isn't a great one but is usually good enough.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
09-02-2008, 06:43 AM #9036QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- Netherlands
- Beiträge
- 148
- Points
- 5.672
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Hi, i want too increase my volume with a prx is this possible?
Code:int sceAudioChangeChannelVolume(int channel, int leftvol, int rightvol);
[SIZE="1"][color=#D1D1FF]______________________________________________________________[/color]
[i]Last edited by basfreak; 01-01-1990 at [color=#666686]12:00 PM[/color][/i].[/SIZE]
-
09-02-2008, 07:55 AM #9037QJ Gamer Blue
Achievements:
- Registriert seit
- Aug 2008
- Beiträge
- 6
- Points
- 2.316
- Level
- 29
- Downloads
- 0
- Uploads
- 0
in order to prove that OSLIB crashes when you mirror a image whose centre X and centre Y or Angle is not at 0, i have purposely edited the mickey example (sprite_src) file which was given as a sample in OSLIB

Before:
Spoiler for the Code before editing:
After:
Spoiler for The code after editing:
I added in this
And so if you just tune mickey around a bit and press select. It will crash. Not just my program.. that mickey source code crashes too.Code:if (osl_keys->pressed.select) oslMirrorImageH(mickey);
somehow if we mirror it vertically it does not happen though
-
09-02-2008, 10:52 AM #9038QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Then it is a bug with the library. Contact the author.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
09-02-2008, 03:44 PM #9039QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Could any one tell me what library "sceCtrlBufferPeekPositiv e" is included in.
Here's my libraries.
Code:#include <pspdebug.h> #include <pspctrl.h> #include <pspkernel.h>
Code:main.o: In function `MainMenu': main.c:(.text+0x9c): undefined reference to `sceCtrlBufferPeekPositive' main.c:(.text+0xfc): undefined reference to `sceCtrlBufferPeekPositive' main.o: In function `main': main.c:(.text+0x230): undefined reference to `sceCtrlBufferPeekPositive' collect2: ld returned 1 exit status make: *** [.elf] Error 1
-
09-02-2008, 05:24 PM #9040QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
add -lpspctrl to the LIBS = line in your make file
Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
09-02-2008, 07:38 PM #9041QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I wanted to code in windows without Cgwin and in Dev-C++ or Visual C#.
Can anyone help me.
-=Double Post Merge =-
A BIG-OL list of tutorials would be nice to.
-=Double Post Merge =-
thanksGeändert von Digikid13 (09-02-2008 um 07:50 PM Uhr) Grund: Automerged Doublepost
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-02-2008, 08:58 PM #9042lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You don't code in cygwin in the first place. cygwin is a compiler while Dev-c++ is an IDE.
psp-programming.com has some nice tutorials but it is recommended to learn how to code on a PC first then move onto the PSP as you'll get a better gasp on C/C++
EDIT: Don't listen to me, freeplay corrected me.Geändert von Anti-QuickJay (09-02-2008 um 09:38 PM Uhr)
-
09-02-2008, 09:25 PM #9043QJ Gamer Platinum
- Registriert seit
- Dec 2005
- Ort
- h0000000rj
- Beiträge
- 12.867
- Points
- 57.528
- Level
- 100
- Downloads
- 0
- Uploads
- 0
cygwin is not a compiler. gcc is a compiler. cygwin is a posix environment for windows.
[I fail @ life]
-
09-03-2008, 07:58 AM #9044QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
my code is this:
how do i make -> turn red once i select it on the menu?Code:printf(" -> example");
i want the first ex in red and the 2nd in blue if you could help that's great :)Code:printf(" ex (red) ex (blue)");
-
09-03-2008, 08:00 AM #9045QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Are you using OSLib?
-
09-03-2008, 08:02 AM #9046QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
no basic C
-
09-03-2008, 08:03 AM #9047
-
09-03-2008, 08:05 AM #9048Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
You may be going about this the wrong way. Get on msn and i'll explain.
-
09-03-2008, 08:07 AM #9049QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Ok going on now thanks.
-
09-03-2008, 08:30 PM #9050QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
09-03-2008, 08:45 PM #9051
I'm not entirely sure that's possible. I could be wrong, but, it's linux based(unix, whatever), so it won't really work on windows.
-
09-03-2008, 10:45 PM #9052QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Well there was one, but the link was dead.
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-04-2008, 03:42 PM #9053
- Registriert seit
- Apr 2008
- Beiträge
- 47
- Points
- 2.658
- Level
- 31
- Downloads
- 0
- Uploads
- 0
Dev-C++ can use either mingw or cygwin as its compiler environment. I tried to set it up once but I got frustrated with its confusing and non-intuitive options and gave up. I use Dev-C++ to compile my windows stuff, but I use SciTE and cygwin for my PSP stuff.
It's possible, but yeah, without that thread I have no clue how to do it. Maybe someone with a little more cygwin experience could take a look?
Also, not to start any trouble, (not intentionally, anyway) but why do people keep suggesting that everyone learn to use C for the PC before they learn to use C for the PSP? It's the same language and it's portable to whatever you can compile for.
I understand that most tutorials and guides are written geared toward pc systems, but apart from stdin/stdout the exact same knowledge typically applies to the PSP.
Maybe it's just me. *shrug*
-
09-04-2008, 04:07 PM #9054QJ Gamer Bronze
- Registriert seit
- Mar 2007
- Beiträge
- 758
- Points
- 8.665
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Because it's a lot easier to run a program on a computer, rather than have to copy it to a PSP?
And because there's more beginner resources? And support?
And the libraries are different?
And because a hello world on the PSP in C is probably around 15 lines, and on a computer, 4 or 5?
-
09-04-2008, 06:47 PM #9055
- Registriert seit
- Apr 2008
- Beiträge
- 47
- Points
- 2.658
- Level
- 31
- Downloads
- 0
- Uploads
- 0
*Copying the program to the PSP is more of a basic OS-use issue than a programming issue.
*C is a portable language, not tied to any specific device or environment. The programmer can read guides on C intended for use on a PC and use the same knowledge on the PSP without needing to code a PC app first.
*If the programmer's goal is to make PSP apps then PC-specific libs are irrelevant to accomplishing that goal. The programmer is better off learning the libs they plan to use for their app rather than the ones they don't.
Eight.Code:#include <pspkernel.h> PSP_MODULE_INFO("hw", 0, 1, 1); int main() { pspDebugScreenPrintf("Hello, world."); sceKernelDelayThread(10000000); sceKernelExitGame(); return 0; }
Two less if you ignore compiler warnings.
At any rate, my point is that if someone wants to make PSP programs in C then it seems sensible to me that they ought to learn to write PSP programs in C rather than for some other platform. You may just as easily say that an aspiring PC programmer should code for the PSP first.
-
09-05-2008, 01:17 AM #9056QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Quicker turnaround times. (Programming->compiling->executing->debugging)
Much easier debugging tools (most IDES come with a GUI debugger which works out of the box)
Tools and compiler are generally complete and more beginner friendly (i.e download and go within 5 minutes).
This generally means that more time is spent actually programming and debugging effectively (and therefore learning) rather then messing around with tools working why X doesn't run on firmware X.XX.
As you said, C and C++ is the same for any platform, so why not have them learn it on a platform that is more beginner 'friendly' for programming?Geändert von yaustar (09-05-2008 um 01:28 AM Uhr)
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
09-05-2008, 02:14 PM #9057
- Registriert seit
- Apr 2008
- Beiträge
- 47
- Points
- 2.658
- Level
- 31
- Downloads
- 0
- Uploads
- 0
Maybe it's just my way of thinking. I dunno. If somebody is completely new to programming at all then maybe they should spend some PC time with something just to get the general idea of how a program works. (But then again, there's LuaPlayer as well...)
I just feel a little put off when I see people told to essentially 'go elsewhere' when they ask questions, even if they're uber-noob questions. Again, maybe it's just my point-of-view, and I do recognize that I am not generally 'mentally sound'. Just seems to me that pointing them to a related C tutorial/manual/text-of-other-kind would be more effective. Generally I see people who don't know C yet get told 'learn PC C' rather than 'you need to focus on improving your syntax', etc, etc.
I'll give you the point with the debugger but I've seen some pretty crappy debuggers out there in IDEs as well.
Meh, maybe you're right. I guess it doesn't matter.
-
09-05-2008, 03:02 PM #9058QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
I think you are mis-interpreting the point. It isn't learn 'PC C', but learn 'C on PC' as turnaround times are quicker, etc. Rather then spending lots of time trying to get tools to work right (how many threads have you seen about installing the toolchain for example), they could spend that time actually learning the language and not get caught up in the PSP specifics.
It is a matter of opinion but the general consensus is to learn programming and the language on the easiest platform possible to minimise the possible number of 'distractions' that get in the way.
I agree there are pretty poor ones out there but both GDB (comes with Code::Blocks and Dev Cpp IIRC) and Visual Studio debugger are pretty standard and robust.I'll give you the point with the debugger but I've seen some pretty crappy debuggers out there in IDEs as well.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
09-05-2008, 06:13 PM #9059QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I still need a way to dev for psp without cgwin emulator.
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
09-05-2008, 07:13 PM #9060
Theres this..
Got it from somewhere on here a while ago. It's iffy at best, though.Code:http://www.megaupload.com/?d=YP4H9HAM


LinkBack URL
About LinkBacks
Mit Zitat antworten


Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum